
/********************************************************************************/
/*     dlg_files.cpp     Shortened calls of the Open & Save filebox (Win32)     */
/*                       By: Josh Fiorio                                        */
/********************************************************************************/

#include "dlg_files.h"

LPSTR OpenFileBox(char *title, char *filter) 
{
	OPENFILENAME ofn;
    char szFileName[MAX_PATH]="";

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
    ofn.hwndOwner = NULL;
    ofn.lpstrFilter = filter;
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
	ofn.nFilterIndex = 1;
	ofn.lpstrTitle = title;

    if(GetOpenFileName(&ofn))
    {
		return (LPSTR) &szFileName;
    }	//end if

	return false; 
}	//end of func.

LPSTR SaveFileBox(char *title, char *filter, char *de) 
{
	OPENFILENAME ofn;
    char szFileName[MAX_PATH]="";

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
    ofn.hwndOwner = NULL;
    ofn.lpstrFilter = filter;
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
	ofn.nFilterIndex = 1;
	ofn.lpstrTitle = title;
	ofn.lpstrDefExt = de;

    if(GetSaveFileName(&ofn))
    {
		return (LPSTR) &szFileName;
    }	//end if

	return false; 
}	//end of func.
